home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 6.0 KB | 198 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: EditCmd.h
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef EDITCMD_H
- #define EDITCMD_H
-
- //----------------------------------------------------------------------------------------
- // Imported Classes
- //----------------------------------------------------------------------------------------
-
- #ifndef FWCLPCMD_H
- #include "FWClpCmd.h"
- #endif
-
- #ifndef FWCONTNT_H
- #include "FWContnt.h"
- #endif
-
- #ifndef FWSELECT_H
- #include "FWSelect.h"
- #endif
-
- #ifndef FWRECEVR_H
- #include "FWRecevr.h"
- #endif
-
- #ifndef FWSTRING_H
- #include "FWString.h"
- #endif
-
- //========================================================================================
- // Forward Declaration
- //========================================================================================
-
- class FW_CEditView;
- class FW_CFrame;
- class CEditViewSelection;
-
- //========================================================================================
- // class CEditViewCommand
- //========================================================================================
-
- class CEditViewCommand : public FW_CClipboardCommand, public FW_MReceiver
- {
- public:
- FW_DECLARE_AUTO(CEditViewCommand)
-
- CEditViewCommand(Environment* ev,
- ODCommandID commandID,
- FW_CFrame* frame,
- FW_Boolean canUndo);
-
- virtual ~ CEditViewCommand();
-
- // ----- FW_CCommand API -----
- virtual void UndoIt(Environment* ev);
- virtual void RedoIt(Environment* ev);
- virtual void SaveUndoState(Environment* ev);
- virtual void SaveRedoState(Environment* ev);
-
- // ----- FW_CClipboardCommand API -----
- virtual void PreCommand(Environment* ev);
- // virtual void CommandDone(Environment* ev);
-
- // ----- FW_MReceiver API -----
- void HandleNotification(Environment* ev, const FW_CNotification& notification);
-
- // ----- New API
- void SetEditView(FW_CEditView* editView);
- void SetSelection(CEditViewSelection* selection);
- CEditViewSelection* GetSelection(Environment* ev) const;
-
- private:
- void RemoveText(Environment* ev);
- void RestoreText(Environment* ev);
- void RemoveAndRestoreText(Environment* ev, FW_ByteCount bytesToRemove,
- const FW_CString& textToRestore);
-
- private:
- FW_Boolean fOwnsSelection;
- FW_CEditView* fEditView;
- //--- Saved data for undo/redo
- FW_CString fPastedText;
- FW_CString fSavedText; // original text (Paste command)
- short fStartOffset;
- short fEndOffset;
- };
-
- //========================================================================================
- // class CEditViewSelContent
- //========================================================================================
-
- class CEditViewSelContent : public FW_CContent
- {
- public:
- FW_DECLARE_AUTO(CEditViewSelContent)
-
- CEditViewSelContent(Environment* ev, FW_CEditView* editview);
- virtual ~CEditViewSelContent();
-
- public:
- //------ FW_CContent API
- virtual void ExternalizeKind(Environment* ev,
- ODStorageUnit* storageUnit,
- FW_CKind* kind,
- FW_StorageKinds storageKind,
- FW_CPromise* promise,
- FW_CCloneInfo* cloneInfo);
- virtual FW_Boolean InternalizeKind(Environment* ev,
- ODStorageUnit* storageUnit,
- FW_CKind* kind,
- FW_StorageKinds storageKind,
- FW_CCloneInfo* cloneInfo);
-
- //------ New API
- FW_CString GetInternalizedText(Environment* ev);
- void ClearSelectedText(Environment* ev);
- void UnselectText(Environment* ev);
- FW_Boolean IsEmpty(Environment* ev) const;
-
- protected:
- FW_CEditView* fEditView;
- FW_CString fInternalizedText; // holds text that was just internalized
- };
-
- //----------------------------------------------------------------------------------------
- inline FW_CString CEditViewSelContent::GetInternalizedText(Environment*)
- {
- return fInternalizedText;
- }
-
- //========================================================================================
- // class CEditViewSelection
- //========================================================================================
-
- class CEditViewSelection : public FW_CSelection
- {
- public:
- FW_DECLARE_AUTO(CEditViewSelection)
-
- CEditViewSelection(Environment* ev, FW_CEditView* editview);
- virtual ~CEditViewSelection();
-
- public:
- virtual void CloseSelection(Environment* ev);
- virtual void ClearSelection(Environment* ev);
- virtual FW_Boolean IsEmpty(Environment* ev) const;
- virtual void SelectAll(Environment* ev);
-
- virtual FW_CContent* GetSelectedContent(Environment* ev);
-
- private:
- CEditViewSelContent* fSelectedContent;
- };
-
- //========================================================================================
- // Prototypes
- //========================================================================================
-
- FW_Boolean InternalizeText(Environment* ev, ODStorageUnit* storageUnit,
- FW_CString& textData, FW_ByteCount maxChars);
-
- //========================================================================================
- // Inlines
- //========================================================================================
-
- //---------------------------------------------------------------------------------------------------
- // CEditViewCommand
- //---------------------------------------------------------------------------------------------------
-
- inline void CEditViewCommand::SetSelection(CEditViewSelection* selection)
- {
- fSelection = selection;
- fOwnsSelection = true; // we can delete our own selection later
- }
-
- inline CEditViewSelection* CEditViewCommand::GetSelection(Environment*) const
- {
- return (CEditViewSelection*)fSelection;
- }
-
- //---------------------------------------------------------------------------------------------------
- // CEditViewSelection
- //---------------------------------------------------------------------------------------------------
-
- inline FW_CContent* CEditViewSelection::GetSelectedContent(Environment*)
- {
- return fSelectedContent;
- }
-
- #endif
-